package threads;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;


public class ParlallelThreads extends Thread{

	File file;
	
	public ParlallelThreads(File file){
		this.file = file;
	}
	
	
	private int getNumberOfLines(File file) throws IOException{
		BufferedReader reader = new BufferedReader(new FileReader(file));
		int lines = 0;
		while (reader.readLine() != null) lines++;
		reader.close();
		
		return lines;
	}
	
	public void printFileInfo(File file) throws IOException{
		System.out.println(this.file.getName() + " has " + getNumberOfLines(this.file) + " lines");
	}

	public void run() {
		try {
			printFileInfo(file);
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
	}

}
